﻿<Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:valc="clr-namespace:ImageLib.Shell.ValueConverter"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
    x:Class="ImageLib.Shell.View.DemoWindow" 
    Title="SVNUG - Image Library Manager"
    mc:Ignorable="d" 
    Height="500" 
    Width="950" 
    SnapsToDevicePixels="True" Initialized="Window_Initialized" Background="{DynamicResource DemoBrush}" >
    <Window.Resources>
        <ResourceDictionary>
            <valc:MatchToBoolConverter x:Key="MatchToBool"/>
            <valc:NotBoolConverter x:Key="NotConverter"/>
            <Style TargetType="{x:Type RadioButton}">
            	<Setter Property="VerticalAlignment" Value="Center"/>
            	<Setter Property="Template" Value="{DynamicResource RadioButtonTemplate}"/>
            	<Setter Property="Foreground" Value="{DynamicResource MainTextBrush}"/>
            	<Setter Property="Content" Value="Icon"/>            	
            	<Setter Property="HorizontalAlignment" Value="Center"/>
            	<Setter Property="MinWidth" Value="30"/>
            	<Setter Property="MinHeight" Value="20"/>
            	<Setter Property="OverridesDefaultStyle" Value="True"/>
            	<Setter Property="Width" Value="35"/>
            	<Setter Property="FontSize" Value="9.333"/>
            	<Setter Property="Height" Value="25"/>
            	<Setter Property="HorizontalContentAlignment" Value="Center"/>
            	<Setter Property="VerticalContentAlignment" Value="Center"/>
            	<Setter Property="Padding" Value="0"/>
            </Style>
            <DataTemplate x:Key="BasicImageDataTemplate">
            	<Grid>            		
            		<Button Content="{Binding Item.Name}" Command="{Binding ClickCommand, Mode=OneWay}"/>
            	</Grid>
            </DataTemplate>        	
        	<ControlTemplate x:Key="RadioButtonTemplate" TargetType="{x:Type RadioButton}">
        		<Grid Background="Transparent">        			
        			<VisualStateManager.VisualStateGroups>
        				<VisualStateGroup x:Name="CommonStates">
        					<VisualState x:Name="Normal"/>
        					<VisualState x:Name="MouseOver"/>
        					<VisualState x:Name="Pressed"/>
        					<VisualState x:Name="Disabled"/>
        				</VisualStateGroup>
        				<VisualStateGroup x:Name="FocusStates">
        					<VisualState x:Name="Unfocused"/>
        					<VisualState x:Name="Focused"/>
        				</VisualStateGroup>
        				<VisualStateGroup x:Name="CheckStates">
        					<VisualState x:Name="Checked">
        						<Storyboard>
        							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="UncheckedOuterBorder">
        								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        							</ObjectAnimationUsingKeyFrames>
        							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CheckedOuterBorder">
        								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
        							</ObjectAnimationUsingKeyFrames>
        						</Storyboard>
        					</VisualState>
        					<VisualState x:Name="Unchecked">
        						<Storyboard>
        							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="UncheckedOuterBorder">
        								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
        							</ObjectAnimationUsingKeyFrames>
        							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CheckedOuterBorder">
        								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/>
        							</ObjectAnimationUsingKeyFrames>
        							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter">
        								<EasingDoubleKeyFrame KeyTime="0" Value="0.4"/>
        							</DoubleAnimationUsingKeyFrames>
        						</Storyboard>
        					</VisualState>
        					<VisualState x:Name="Indeterminate"/>
        				</VisualStateGroup>
        				<VisualStateGroup x:Name="ValidationStates">
        					<VisualState x:Name="Valid"/>
        					<VisualState x:Name="InvalidFocused"/>
        					<VisualState x:Name="InvalidUnfocused"/>
        				</VisualStateGroup>
        			</VisualStateManager.VisualStateGroups>
        			<Border x:Name="UncheckedOuterBorder" BorderBrush="#FF414141" BorderThickness="1" Background="{x:Null}">
        				<Border x:Name="UncheckedInnerBorder" BorderBrush="#FF585858" BorderThickness="1" Margin="0">
        					<Border.Background>
        						<LinearGradientBrush EndPoint="0.434,0.067" StartPoint="0.566,0.933">
        							<GradientStop Color="#FF373737" Offset="0"/>
        							<GradientStop Color="#FF4B4B4B" Offset="1"/>
        						</LinearGradientBrush>
        					</Border.Background>
        				</Border>
        			</Border>
        			<Border x:Name="CheckedOuterBorder" BorderBrush="#FF2F2F2F" BorderThickness="1" Background="Black" Visibility="Hidden">
        				<Border x:Name="CheckedInnerBorder" BorderBrush="#FF4B4B4B" BorderThickness="1" Margin="1,1,0,0">
        					<Border.Background>
        						<LinearGradientBrush EndPoint="0.434,0.067" StartPoint="0.566,0.933">
        							<GradientStop Color="#FF1D1D1D" Offset="0"/>
        							<GradientStop Color="#FF373737" Offset="1"/>
        						</LinearGradientBrush>
        					</Border.Background>
        				</Border>
        			</Border>
        			<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        		</Grid>
        		<ControlTemplate.Triggers>
        			<Trigger Property="HasContent" Value="True">
        				<Setter Property="FocusVisualStyle">
        					<Setter.Value>
        						<Style>
        							<Setter Property="Control.Template">
        								<Setter.Value>
        									<ControlTemplate>
        										<Rectangle Margin="14,0,0,0" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
        									</ControlTemplate>
        								</Setter.Value>
        							</Setter>
        						</Style>
        					</Setter.Value>
        				</Setter>
        				<Setter Property="Padding" Value="4,0,0,0"/>
        			</Trigger>
        			<Trigger Property="IsEnabled" Value="False">
        				<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        			</Trigger>
        		</ControlTemplate.Triggers>
        	</ControlTemplate>
			<Style x:Key="ButtonFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2" SnapsToDevicePixels="true"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#F3F3F3" Offset="0"/>
			<GradientStop Color="#EBEBEB" Offset="0.5"/>
			<GradientStop Color="#DDDDDD" Offset="0.5"/>
			<GradientStop Color="#CDCDCD" Offset="1"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
		<Style x:Key="ButtonStyle2-NOicon" TargetType="{x:Type Button}">
			<Setter Property="FocusVisualStyle" Value="{DynamicResource ButtonFocusVisual}"/>
			<Setter Property="Background" Value="{DynamicResource ButtonNormalBackground}"/>
			<Setter Property="BorderBrush" Value="{DynamicResource ButtonNormalBorder}"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="HorizontalContentAlignment" Value="Center"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Padding" Value="1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Grid Width="Auto" Height="22" Opacity="1">
							<Grid Opacity="0.5">
								<Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" Opacity="1" SnapsToDevicePixels="true" BorderBrush="#FF000000" RenderDefaulted="{TemplateBinding IsDefaulted}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}">
									<Microsoft_Windows_Themes:ButtonChrome.Background>
										<LinearGradientBrush EndPoint="0,1" MappingMode="RelativeToBoundingBox" SpreadMethod="Pad">
											<GradientStop Color="#FF646464" Offset="0"/>
											<GradientStop Color="#FF3C3C3C" Offset="0.5"/>
											<GradientStop Color="#FF141414" Offset="1"/>
										</LinearGradientBrush>
									</Microsoft_Windows_Themes:ButtonChrome.Background>
								</Microsoft_Windows_Themes:ButtonChrome>
								<Rectangle Fill="{x:Null}" StrokeThickness="1" RadiusX="1.75" RadiusY="1.75" Margin="1,1,1,1" VerticalAlignment="Stretch">
									<Rectangle.Stroke>
										<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
											<GradientStop Color="#FFA0A0A0" Offset="0"/>
											<GradientStop Color="#FF787878" Offset="1"/>
										</LinearGradientBrush>
									</Rectangle.Stroke>
								</Rectangle>
							</Grid>
							<TextBlock HorizontalAlignment="Stretch" Margin="2" TextWrapping="Wrap" Text="{TemplateBinding Content}" Foreground="White" TextAlignment="Center" Padding="0,2,0,0" FontFamily="Verdana" FontSize="11" Width="Auto"/>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsKeyboardFocused" Value="true">
								<Setter Property="RenderDefaulted" TargetName="Chrome" Value="true"/>
							</Trigger>
							<Trigger Property="ToggleButton.IsChecked" Value="true">
								<Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
							</Trigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="#ADADAD"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
        </ResourceDictionary>
    </Window.Resources>
	<Window.DataContext>
		<Binding Mode="OneWay" Path="Main" Source="{StaticResource Locator}"/>
	</Window.DataContext>
    <Grid Grid.IsSharedSizeScope="True">    	
    	<Border BorderThickness="1" >
    		<Grid >
    			<Grid.ColumnDefinitions>
    				<ColumnDefinition MinWidth="150" Width="210"/>
    				<ColumnDefinition Width="5"/>
    				<ColumnDefinition/>
    			</Grid.ColumnDefinitions>
    			<Grid>
    				<Grid.RowDefinitions>
    					<RowDefinition Height="Auto" SharedSizeGroup="HeaderRow"/>
    					<RowDefinition/>
    				</Grid.RowDefinitions>
    				<Border BorderThickness="1" >
    					<Grid>
    						<Button Content="Add Library" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding MainCommand}" CommandParameter="AddLibrary" Margin="0,4"/>
    					</Grid>
    				</Border>
    				<Grid Grid.Row="1" Margin="0,2,0,0">
    					<Grid.RowDefinitions>
    						<RowDefinition Height="Auto"/>
    						<RowDefinition/>
    					</Grid.RowDefinitions>
    					<Grid Margin="4">
    						<Grid.ColumnDefinitions>
    							<ColumnDefinition/>
    							<ColumnDefinition Width="Auto"/>
    							<ColumnDefinition Width="Auto"/>
    						</Grid.ColumnDefinitions>
    						<Rectangle Fill="{DynamicResource SectionBorderBrush}" Width="1" StrokeThickness="0" Grid.Column="1" Margin="3,0"/>
    						<ComboBox ItemsSource="{Binding Libraries}" BorderThickness="1,1,1,0" VerticalContentAlignment="Center" VerticalAlignment="Center" ItemTemplate="{DynamicResource LibraryItemDataTemplate}" >
    							<ComboBox.Resources>
    								<DataTemplate x:Key="LibraryItemDataTemplate">
    									<Grid>    									
    										<Button Command="{Binding ClickCommand, Mode=OneWay}" Content="{Binding Item.Name}"/>
    									</Grid>
    								</DataTemplate>
    							</ComboBox.Resources>
    						</ComboBox>
    						<StackPanel Orientation="Horizontal" Grid.Column="2" VerticalAlignment="Center">
    							<RadioButton Content="ALL" Command="{Binding MainCommand}" CommandParameter="GetCurrentLibraryImages" IsChecked="{Binding ShowAllImages}" />
    							<RadioButton Command="{Binding MainCommand}" CommandParameter="GetCurrentFolderImages" IsChecked="{Binding ShowAllImages, Converter={StaticResource NotConverter}}">
    								
    							</RadioButton>
    						</StackPanel>
    					</Grid>
    					<ListBox ItemsSource="{Binding Folders}" SelectedItem="{Binding CurrentFolder}" Grid.Row="1" BorderThickness="1,1,1,1" />
    				</Grid>
    			</Grid>
    			<Grid Grid.Column="2">
    				<Grid.RowDefinitions>
    					<RowDefinition Height="Auto" SharedSizeGroup="HeaderRow"/>
    					<RowDefinition/>
    				</Grid.RowDefinitions>
    				<Grid>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition/>
    						<ColumnDefinition Width="Auto"/>
    					</Grid.ColumnDefinitions>
    					<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Column="1">
    						<StackPanel Orientation="Horizontal">
    							<RadioButton IsChecked="{Binding ImageListType, ConverterParameter=Small Icons, Converter={StaticResource MatchToBool}}" Command="{Binding MainCommand}" CommandParameter="Small Icons">
    								<Path Data="M10,10 L14,10 14,14 10,14 z M5,10 L9,10 9,14 5,14 z M0,10 L4,10 4,14 0,14 z M10,5 L14,5 14,9 10,9 z M5,5 L9,5 9,9 5,9 z M0,5 L4,5 4,9 0,9 z M10,0 L14,0 14,4 10,4 z M5,0 L9,0 9,4 5,4 z M0,0 L4,0 4,4 0,4 z" Fill="#FFFFFFFF" HorizontalAlignment="Center" Height="14" Margin="0" Opacity="0.3" Stretch="Fill" Stroke="{x:Null}" VerticalAlignment="Center" Width="14" />
    								
    							</RadioButton>
    							<RadioButton IsChecked="{Binding ImageListType, ConverterParameter=Large Icons, Converter={StaticResource MatchToBool}}" Command="{Binding MainCommand}" CommandParameter="Large Icons">
    								
    							</RadioButton>
    							<RadioButton IsChecked="{Binding ImageListType, ConverterParameter=Tiles, Converter={StaticResource MatchToBool}}" Command="{Binding MainCommand}" CommandParameter="Tiles">
    								
    							</RadioButton>
    							<RadioButton IsChecked="{Binding ImageListType, ConverterParameter=Content, Converter={StaticResource MatchToBool}}" Command="{Binding MainCommand}" CommandParameter="Content">
    								
    							</RadioButton>
    						</StackPanel>
    					</StackPanel>
    					<StackPanel Grid.IsSharedSizeScope="True" Opacity="0.3">
    						<Grid>
    							<Grid.ColumnDefinitions>
    								<ColumnDefinition Width="Auto" SharedSizeGroup="CaptionColumn"/>
    								<ColumnDefinition/>
    							</Grid.ColumnDefinitions>
    							<TextBlock HorizontalAlignment="Right" Padding="5,0" Text="Library:"/>
    							<TextBlock HorizontalAlignment="Left" Padding="5,0" Text="{Binding CurrentLibraryName}" ToolTip="{Binding CurrentLibraryPath}" Grid.Column="1" />
    						</Grid>
    						<Grid>
    							<Grid.ColumnDefinitions>
    								<ColumnDefinition Width="Auto" SharedSizeGroup="CaptionColumn"/>
    								<ColumnDefinition/>
    							</Grid.ColumnDefinitions>
    							<TextBlock HorizontalAlignment="Right" Padding="5,0" Text="Folder:" />
    							<TextBlock HorizontalAlignment="Left" Padding="5,0" Text="{Binding CurrentFolder}" Grid.Column="1" />
    						</Grid>
    					</StackPanel>
    				</Grid>
    				<ListBox Grid.Row="1" ItemsSource="{Binding Images}" Margin="0,2,0,0" Background="{x:Null}">
    					<ListBox.Resources>
    						<DataTemplate x:Key="SmallIconDataTemplate">
    							<Grid Margin="5">
    								<Grid.ColumnDefinitions>
    									<ColumnDefinition Width="Auto"/>
    									<ColumnDefinition/>
    								</Grid.ColumnDefinitions>
    								<Grid.Effect>
    									<DropShadowEffect BlurRadius="10"/>
    								</Grid.Effect>           		
    								<Button Command="{Binding ClickCommand, Mode=OneWay}" Style="{DynamicResource ImageButtonStyle}">
    									<Button.Resources>
    										<Style x:Key="ButtonFocusVisual">
    											<Setter Property="Control.Template">
    												<Setter.Value>
    													<ControlTemplate>
    														<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
    													</ControlTemplate>
    												</Setter.Value>
    											</Setter>
    										</Style>
    										<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
    											<GradientStop Color="#F3F3F3" Offset="0"/>
    											<GradientStop Color="#EBEBEB" Offset="0.5"/>
    											<GradientStop Color="#DDDDDD" Offset="0.5"/>
    											<GradientStop Color="#CDCDCD" Offset="1"/>
    										</LinearGradientBrush>
    										<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
    										<Style x:Key="ImageButtonStyle" TargetType="{x:Type Button}">
    											<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
    											<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
    											<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
    											<Setter Property="BorderThickness" Value="1"/>
    											<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    											<Setter Property="HorizontalContentAlignment" Value="Center"/>
    											<Setter Property="VerticalContentAlignment" Value="Center"/>
    											<Setter Property="Padding" Value="1"/>
    											<Setter Property="Template">
    												<Setter.Value>
    													<ControlTemplate TargetType="{x:Type Button}">    														
    														<Border HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Background="#00000000">    															
    															<ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Height="25" Width="25"/>    														
    														</Border>    														
    													</ControlTemplate>
    												</Setter.Value>
    											</Setter>
    										</Style>
    									</Button.Resources>
    									<Image Source="{Binding FullPath, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="25" Height="25"/>			
    								</Button>
    								<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding Item.Name}" Grid.Column="1" Padding="5,0"/>
    							</Grid>
    						</DataTemplate>
    						<ItemsPanelTemplate x:Key="SmallIconItemsPanelTemplate">
    							<UniformGrid IsItemsHost="True" Rows="20" Columns="3"/>
    						</ItemsPanelTemplate>
    					</ListBox.Resources>
    				</ListBox>
    			</Grid>
    			<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" Margin="-2,0" Background="#00000000" />
    		</Grid>
        
    	</Border>
        
    </Grid>
</Window>
